﻿<?php
 
iif (get_magic_quotes_gpc()) 
{
    function stripslashes_deep($value)
    {
        $value = is_array($value) ?
                    array_map('stripslashes_deep', $value) :
                    stripslashes($value);
        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}

date_default_timezone_set('Asia/Saigon');

// error handler function
function nowchatErrorHandler($errno, $errstr, $errfile, $errline)
{
    switch ($errno) 
    {
        case E_USER_ERROR:
            echo "<div class='Error'>";
            echo "<p class='Fatal'><strong>Có lỗi</strong> [code $errno] $errstr<br />";
            echo "  tại dòng $errline file $errfile";
            echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br /></p>";
            echo "</div>";
            exit(1);
            break;
            
        case E_USER_WARNING:
            echo "<div class='Error'>";
            echo "<p class='Warning'><strong>Cảnh báo</strong> [code $errno] $errstr ($errfile-$errline)</p>";
            echo "</div>";
            break;
            
        case E_USER_NOTICE:
            echo "<div class='Error'>";
            echo "<p class='Info'><strong>Chú ý<strong> [code $errno] $errstr ($errfile-$errline)</p>";
            echo "</div>";
            break;
            
        default:
            break;
    }

    /* Don't execute PHP internal error handler */
    return true;
}

$old_error_handler = set_error_handler("nowchatErrorHandler", E_ALL);

?>